package us.mooresr.geartrack.client.events;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import us.mooresr.geartrack.shared.model.Location;
import com.google.gwt.event.shared.HasHandlers;

public class LocationChangedEvent extends
		GwtEvent<LocationChangedEvent.LocationChangedHandler> {

	public static Type<LocationChangedHandler> TYPE = new Type<LocationChangedHandler>();
	private Location location;

	public interface LocationChangedHandler extends EventHandler {
		void onLocationChanged(LocationChangedEvent event);
	}

	public LocationChangedEvent(Location location) {
		this.location = location;
	}

	public Location getLocation() {
		return location;
	}

	@Override
	protected void dispatch(LocationChangedHandler handler) {
		handler.onLocationChanged(this);
	}

	@Override
	public Type<LocationChangedHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<LocationChangedHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Location location) {
		source.fireEvent(new LocationChangedEvent(location));
	}
}
